#include <iostream>
#include <algorithm>
using namespace std;

signed main()
{
	string s;
	cin>>s;
	while(s.size()<4){
		s.insert(s.begin(),'0');
	}
	if(s[0]==s[1]&&s[1]==s[2]&&s[2]==s[3]){
		cout<<s<<" - "<<s<<" = "<<"0000";
		return 0;
	}
	string s1,s2;
	int num1,num2;
	do{
		sort(s.begin(),s.end());
		s2=s;
		reverse(s.begin(),s.end());
		s1=s;
		num1 = stoi(s1);
		num2 = stoi(s2);
		s=to_string(num1-num2);
		cout<<s1<<" - "<<s2<<" = ";
		while(s.size()<4){
			s.insert(s.begin(),'0');
		}
		cout<<s<<endl;
	}while(s!="6174"&&s!="0000");
	return 0;
 } 
